import {ref} from 'vue'
import axios from 'axios';
import 'md-editor-v3/lib/style.css';

const responseText = ref('');


function submitForm(prompt: string, email: string, url: string) {
    const form = new FormData();
    form.append('prompt', prompt);
    form.append('email', email);

    try {
        // 将返回结果存入文本框中
        // responseText.value = JSON.stringify(response.data.message, null, 2);
        return axios.post(url, form, {
            headers: {
                'Content-Type': 'multipart/form-data'
            }
        })
    } catch (error: any) {
        console.error('Error:', error);
        responseText.value = 'An error occurred: ' + error.message;
    }
}

function resetChatHistory(url: string) {
    try {
        return axios.delete(url)
    } catch (error: any) {
        console.error('Error:', error);
        responseText.value = 'An error occurred: ' + error.message;
    }
}


export {
    submitForm, resetChatHistory
}